package com.sloera.thread;

import com.sloera.enums.CountryEnum;

import java.util.concurrent.CountDownLatch;

/**
 * @author sloera
 * @create 2020/4/27
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        closeDoor();
    }

    public static void closeDoor() throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "\t结束子任务");
                countDownLatch.countDown();
            }, CountryEnum.forEachCountryEnum(i + 1).getRetMessage()).start();
        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName() + "\t 终止总任务");
    }
}
